package com.cskaoyan.javase.oop1._7exercise._1pvz;

/**
 * 僵尸类
 *
 * @since 17:19
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Zombie {
    String name;
    int hp;
    int damage;
    double speed;
    // 持有植物类对象的引用,方便去获取植物的属性
    Plant p;


    public void move() {
        // 这里的移动也需要一个目标,向植物移动
        System.out.println(name + "正在向植物" + p.name + "以" + speed + "的速度移动!");
    }

    public void attack() {
        System.out.println(name + "正在攻击植物" + p.name);
    }

    public void beAttacked() {
        System.out.println(name + "被" + p.name + "攻击了,剩余" + (hp - p.damage) + "点血量!");
    }

    public void eat() {
        System.out.println(name + "吃掉了花园主人的脑子,真香!");
    }

    public Zombie() {
    }

    public Zombie(String name, int hp, int damage, double speed, Plant p) {
        this.name = name;
        this.hp = hp;
        this.damage = damage;
        this.speed = speed;
        this.p = p;
    }
}
